package com.c6906.vdam.das.model.entity;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.c6906.vdam.das.common.IDGenUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@TableName("T_VEHICLES_PARKING")
@NoArgsConstructor
@AllArgsConstructor
public class VehiclesParkingData {
    @TableId
    private Long tripId;
    private String vehiclesCode;
    private String vehPlateNum;
    private String terminalSn;
    private Date startTime;
    private Date endTime;
    private Double longitude;
    private Double latitude;
    private Long duration;
    private String apiResult;
    private String poiTag;
    private String poiName;
    private Date createTime;
    private Date updateTime;
    private Integer status;
    private Integer isDeleted;

    public VehiclesParkingData(TerminalData terminalData, TerminalBusinessInfo terminalBusinessInfo) {
        this.tripId = IDGenUtil.generateId();
        this.vehiclesCode = terminalBusinessInfo.getVehiclesCode();
        this.vehPlateNum = terminalBusinessInfo.getVehPlateNum();
        this.terminalSn = terminalBusinessInfo.getTerminalSn();
        this.startTime = DateUtil.parseDateTime(terminalData.getTerminalTime());
        this.longitude = Double.valueOf(terminalData.getLongitude());
        this.latitude = Double.valueOf(terminalData.getLatitude());
        this.createTime = DateUtil.date();
    }
}
